package com.iman.fetion.servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.iman.fetion.FetionMessage;

public class SmsCodeServlet extends HttpServlet {

	/**
	 * The doGet method of the servlet. <br>
	 *
	 * This method is called when a form has its tag value method equals to get.
	 * 
	 * @param request the request send by the client to the server
	 * @param response the response send by the server to the client
	 * @throws ServletException if an error occurred
	 * @throws IOException if an error occurred
	 */

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
//		String body = "PicCertSessionId=" + picId + "&PicCertCode=" + picCode
//		+ "&MobileNo=" + tmpMobile;		
		String picId=request.getParameter("picId");
		String picCode=request.getParameter("picCode");
		String tmpMobile=request.getParameter("tmpMobile");
		
		FetionMessage fetion=new FetionMessage();	
		
		fetion.picId=picId;
		fetion.picCode=picCode;
		fetion.tmpMobile=tmpMobile;
		
		String status=fetion.getSmsCode();
		
		System.out.println("GetSMSCODE tmpMobile="+tmpMobile+" picCode="+picCode+" picId="+picId);
		
		response.setContentType("text/xml");
		PrintWriter out = response.getWriter();
		out.write(status);
		out.flush();
		out.close();
	}

	private String getXml(String picId,String picContent){
		String xml="<result>";
		xml+="<picId>"+picId+"</picId>";
		xml+="<picContent>"+picContent+"</picContent>";		
		xml+="</result>";
		return xml;
	}

}
